/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * newsemestreunidad.java
 *
 * Created on 08/10/2011, 12:09:53 PM
 */

package proyectocatalina.mantenimiento;

import CapadeDatos.daosemestreunidad;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import modelo.beancarrera;
import modelo.beanper;
import modelo.beanturno;
import proyectocatalina.Principal;
import proyectocatalina.mantenimiento.*;

/**
 *
 * @author Hans
 */
public class newsemestreunidad extends javax.swing.JInternalFrame{
static  String cod;
static String codlistado;
static int y;

beanper[] matriz2;
beanturno[] matriz3;
beancarrera[] matriz1;
    /** Creates new form newsemestreunidad */
    public newsemestreunidad() throws Exception {
 initComponents();
             LogicadeNegocio.combocarrera1 carrera2 = new LogicadeNegocio.combocarrera1(jCombo);
carrera2.cargarcarrera();
matriz1 = carrera2.semestre();
jCombo.setSelectedIndex(0);
//  LogicadeNegocios.comboper per = new LogicadeNegocios.comboper(jcombo2);
//per.cargarper();
//matriz2 = per.semestre();
//jcombo2.setSelectedIndex(0);
LogicadeNegocio.comboper per2 = new LogicadeNegocio.comboper(jcombo2);
per2.cargarper();
matriz2 = per2.semestre();
jcombo2.setSelectedIndex(0);

LogicadeNegocio.comboturno1 turno2 = new LogicadeNegocio.comboturno1(jcombo3);
turno2.cargarturno();
matriz3 = turno2.semestre();
jcombo3.setSelectedIndex(0);

       
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jcombo3 = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jcombo4 = new javax.swing.JComboBox();
        jcombo2 = new javax.swing.JComboBox();
        jCombo = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Buscar Semestre"));

        jLabel2.setText("Periodo Lectivo");

        jcombo3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jcombo3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcombo3ActionPerformed(evt);
            }
        });

        jLabel3.setText("Turno");

        jLabel1.setText("Carrera");

        jLabel4.setText("Semestre:");

        jcombo4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII" }));

        jcombo2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jcombo2, 0, 312, Short.MAX_VALUE)
                            .addComponent(jcombo4, 0, 312, Short.MAX_VALUE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCombo, 0, 326, Short.MAX_VALUE)
                            .addComponent(jcombo3, 0, 326, Short.MAX_VALUE))))
                .addContainerGap(14, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jcombo3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addComponent(jcombo2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcombo4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButton1.setText("INGRESAR/RETIRAR UNIDADES O CAMBIAR ESTADO DEL SEMESTRE");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("EDITAR SEMESTRE");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Ver Alumnos Que Pertenecen al Semestre");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(3, 3, 3)
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jcombo3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcombo3ActionPerformed

        jcombo3.getItemAt(jcombo3.getSelectedIndex());
        // TODO add your handling code here:
}//GEN-LAST:event_jcombo3ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
String codcarr;
String codper;
int codturno;
String desc=(String) jcombo4.getSelectedItem();

codcarr=matriz1[jCombo.getSelectedIndex()].getCodigo();

codper=matriz2[jcombo2.getSelectedIndex()].getCod();


codturno = matriz3[jcombo3.getSelectedIndex()].getCod_turno();
   JOptionPane.showMessageDialog(null,"encontrado "+ codcarr+"---"+
                codper+"---"+
                    codturno+"---"+
                   desc);
  cod=(String)daosemestreunidad.ubicarsemestre(
           codcarr,
                desc,
                    codturno,
                   codper);//recoger datos de alum
       
     try {
            proyectocatalina.mantenimiento.listadeunidades ingresar = new   proyectocatalina.mantenimiento.listadeunidades();
            int x = this.getSize().width - ingresar.getSize().width;
            int y = Principal.panel.getSize().height - ingresar.getSize().height;
            ingresar.setLocation(x/2,y/2);
            Principal.panel.add(ingresar);
            ingresar.show();
        } catch (Exception ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        }
  
        try {
            semestre_unidad ingresar = new semestre_unidad();        
            int x = this.getSize().width - ingresar.getSize().width;
            int y = Principal.panel.getSize().height - ingresar.getSize().height;
            ingresar.setLocation(x/2,y/2);
            Principal.panel.add(ingresar);
            ingresar.show();
        } catch (Exception ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        }
//            new semestre_unidad().setVisible(true);
            // TODO add your handling code here:
      
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        try {
           String codcarr;
String codper;
int codturno;
String desc=(String) jcombo4.getSelectedItem();

codcarr=matriz1[jCombo.getSelectedIndex()].getCodigo();

codper=matriz2[jcombo2.getSelectedIndex()].getCod();


codturno=matriz3[jcombo3.getSelectedIndex()].getCod_turno();
   JOptionPane.showMessageDialog(null,"encontrado "+ codcarr+"---"+
                codper+"---"+
                    codturno+"---"+
                   desc);
  cod=(String)daosemestreunidad.ubicarsemestre(
           codcarr,
                desc,
                    codturno,
                   codper);
//            new editarsemestre().setVisible(true);
     try {
            editarsemestre ingresar = new editarsemestre();        
            int x = this.getSize().width - ingresar.getSize().width;
            int y = Principal.panel.getSize().height - ingresar.getSize().height;
            ingresar.setLocation(x/2,y/2);
            Principal.panel.add(ingresar);
            ingresar.show();
        } catch (Exception ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        }

            // TODO add your handling code here:
        } catch (Exception ex) {
            Logger.getLogger(newsemestreunidad.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
y=1;
        String codcarr;
String codper;
int codturno;
String desc=(String) jcombo4.getSelectedItem();

codcarr=matriz1[jCombo.getSelectedIndex()].getCodigo();

codper=matriz2[jcombo2.getSelectedIndex()].getCod();


codturno=matriz3[jcombo3.getSelectedIndex()].getCod_turno();
   JOptionPane.showMessageDialog(null,"encontrado "+ codcarr+"---"+
                codper+"---"+
                    codturno+"---"+
                   desc);
    codlistado=(String)daosemestreunidad.ubicarsemestre(
           codcarr,
                desc,
                    codturno,
                   codper);
    
       try {
            alumnosdesemestre ingresar = new alumnosdesemestre();        
            int x = this.getSize().width - ingresar.getSize().width;
            int y = Principal.panel.getSize().height - ingresar.getSize().height;
            ingresar.setLocation(x/2,y/2);
            Principal.panel.add(ingresar);
            ingresar.show();
        } catch (Exception ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        }




        // TODO add your handling code here:
    }//GEN-LAST:event_jButton3ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new newsemestreunidad().setVisible(true);
                } catch (Exception ex) {
                    Logger.getLogger(newsemestreunidad.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JComboBox jCombo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JComboBox jcombo2;
    private javax.swing.JComboBox jcombo3;
    private javax.swing.JComboBox jcombo4;
    // End of variables declaration//GEN-END:variables

}
